Milestone 2: Collision Operator¶

In [ ]:
import numpy as np
from src.simulation import LatticeBoltzmann

Parameters¶

In [ ]:
size_x = 20
size_y = 12
n_steps = 200
omega = 1.3

Test 1¶

Uniform density with a slightly higher value at the center.

In [ ]:
# center
c_w = 4
c_x = size_x//2 - c_w//2
c_y = size_y//2 - c_w//2
# uniform density
density = np.ones((size_y, size_x)) * 0.1
# higher value at center
density[c_y:c_y+c_w, c_x:c_x+c_w] = 1.0
# create lattice
lattice = LatticeBoltzmann(size_x, size_y, omega=omega, init_density=density)
In [ ]:
# run simulation
lattice.step(n_steps)
lattice.display_animation()

Test 2¶

Random initial density and velocity distribution.

In [ ]:
# random density
density = np.random.rand(size_y, size_x)
# random velocity
velocity = np.random.rand(2, size_y, size_x) * 0.2 - 0.1
# create lattice
lattice = LatticeBoltzmann(size_x, size_y, omega=omega, init_density=density)
In [ ]:
# run simulation
lattice.step(n_steps)
lattice.display_animation()